<?php
declare (strict_types = 1);

namespace app\api\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class UserCoupon extends Model
{
    protected $table = 'ea_user_coupon';

    /**
     * @param $user_id
     * @return int
     * 用户拥有多少张可用的优惠券
     */
    public function userCouponNum($user_id)
    {
        $couponNum = self::where(['user_id'=>$user_id,'status'=>0])->count();
        return $couponNum;
    }
}
